{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="layui-form p-page">
	<h3 class="pb-2">发票详情</h3>
	<table class="layui-table layui-table-form">
		<tr>
			<td class="layui-td-gray-2">开票金额</td>
			<td class="blue">{$detail.amount} 元</td>
			<td class="layui-td-gray">开票类型</td>
			<td>
				{eq name="$detail.invoice_type" value="1"}增值税专用发票{/eq}
				{eq name="$detail.invoice_type" value="2"}普通发票{/eq}
				{eq name="$detail.invoice_type" value="3"}专业发票{/eq}
			</td>
			<td class="layui-td-gray">开票主体</td>
			<td>{$detail.subject}</td>
		</tr>
		<tr>
			<td class="layui-td-gray">抬头类型</td>
			<td>
				{eq name="$detail.types" value="1"}企业{/eq}
				{eq name="$detail.types" value="2"}个人{/eq}
			</td>
			<td class="layui-td-gray">开票抬头</td>
			<td>{$detail.invoice_title}</td>
			<td class="layui-td-gray">电话号码</td>
			<td>{$detail.invoice_phone}</td>
		</tr>
		<tr class="invoice-type" {eq name="$detail.types" value="2"}style="display:none"{/eq}>
			<td class="layui-td-gray-2">纳税人识别号</td>
			<td>{$detail.invoice_tax}</td>
			<td class="layui-td-gray">开户行</td>
			<td>{$detail.invoice_bank}</td>
			<td class="layui-td-gray">银行账号</td>
			<td>{$detail.invoice_account}</td>
		</tr>
		<tr class="invoice-type" {eq name="$detail.types" value="2"}style="display:none"{/eq}>
			<td class="layui-td-gray-2">银行营业网点</td>
			<td>{$detail.invoice_banking}</td>
			<td class="layui-td-gray">地址</td>
			<td colspan="3">{$detail.invoice_address}</td>
		</tr>
		{if condition="$detail.contract_id > 0"}
		<tr>
		<td class="layui-td-gray">关联的合同</td>
			<td colspan="5">{$detail.contract_name|default=''}</td>
		</tr>
		{/if}
		{if condition="$detail.project_id > 0"}
		<tr>
		<td class="layui-td-gray">关联的项目</td>
			<td colspan="5">{$detail.project_name|default=''}</td>
		</tr>
		{/if}
		{notempty name="$detail.remark"}
		<tr>
			<td class="layui-td-gray">备注信息</td>
			<td colspan="5">{$detail.remark}</td>
		</tr>
		{/notempty}
		{notempty name="$detail.file_ids"}
		<tr>
			<td class="layui-td-gray">关联附件</td>
			<td colspan="5">
				<div class="layui-row">
					{volist name="$detail.file_array" id="vo"}
					<div class="layui-col-md4" id="uploadFile{$vo.id}">{:file_card($vo,'view')}</div>
					{/volist}
				</div>
			</td>
		</tr>
		{/notempty}
		{if ( $detail.open_status gt 0)}
		<tr>
			<td class="layui-td-gray">发票号码</td>
			<td>{$detail.code}{eq name="$detail.open_status" value="2"}<span class="yellow">『已作废』</span>{/eq}</td>
			<td class="layui-td-gray">开票人</td>
			<td>{$detail.open_admin_name}</td>
			<td class="layui-td-gray">开票日期</td>
			<td colspan="3">{$detail.open_time|date='Y-m-d'}</td>
		</tr>
		<tr>
			<td class="layui-td-gray">物流单号</td>
			<td colspan="5">{$detail.delivery}</td>
		</tr>
		<tr>
			<td class="layui-td-gray">			
				<div class="layui-input-inline">发票附件</div>
				<div class="layui-input-inline">
					<button type="button" class="layui-btn layui-btn-xs" id="uploadBtn"><i class="layui-icon"></i></button>
				</div>
			</td>
			<td colspan="5">
				<div class="layui-row" id="uploadBox">
					<input type="hidden" data-type="file" name="other_file_ids" value="{$detail.other_file_ids}">
					{notempty name="$detail.other_file_ids"}
					{volist name="$detail.other_file_array" id="vo"}
					<div class="layui-col-md4" id="uploadFile{$vo.id}">{:file_card($vo)}</div>
					{/volist}
					{/notempty}
				</div>
			</td>
		</tr>
		{/if}
	</table>
	<div id="checkBox" class="pt-3" data-status="{$detail.check_status}" data-id="{$detail.id}" data-checkflowid="{$detail.check_flow_id}"></div>
</div>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
<script>
const invoice_id = {$detail.id};
const moduleInit = ['tool','oaCheck','uploadPlus'];
function gouguInit() {
	var form = layui.form,tool=layui.tool, oaCheck=layui.oaCheck,uploadPlus = layui.uploadPlus;	
	oaCheck.init({
		check_name:'invoice'
	});
	//相关附件上传
	var attachment = new uploadPlus({
		"attachment":{
			uidDelete:true,
			ajaxSave:function(val){
				$.ajax({
					url: "/finance/api/upload_invoice",
					type:'post',
					data:{
						id:invoice_id,
						other_file_ids:val
					},
					success: function (e) {
						location.reload();
					}
				})
			},
			ajaxDelete:function(val){
				$.ajax({
					url: "/finance/api/upload_invoice",
					type:'post',
					data:{
						id:invoice_id,
						other_file_ids:val
					},
					success: function (e) {
						location.reload();
					}
				})
			}
		}
	})
}
</script>
{/block}
<!-- /脚本 -->